<?php

namespace App\Service\GuildManage;

use App\Model\GuildManage\GuildAccount;
use App\Service\BaseService;

class ListService extends BaseService
{
    /**
     * 主要方法
     * @return array
     */
    public function handle(): array
    {
        $userId = $this->getUserId();

        $list = (new GuildAccount)->where('user_id', $userId)
            ->select('account', 'real_name', 'id_card', 'type', 'id')
            ->get();

        $return['list'] = [];
        foreach ($list as $item) {
            $return['list'][] = [
                'account_id' => $item->id,
                'account_string' => ($item->type == 1 ? '银行卡:' : '支付宝:') . $item->account,
                'real_name_string' => '收款人:' . $item->real_name,
                'account' => $item->account,
                'account_name' => ($item->type == 1 ? '中国银联' : '支付宝')
            ];
        }

        return $return;
    }
}